<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<script>
function add_attentioncommunity(cid) {
	var user =  '${user}';
    var a=$.cookie('individual');
	var buildingId = document.getElementById("buildingId").value;
	if ('${user}'=="nobody" || !a)
	{
		alert("请先登录！");
	    window.location.href='/sks/privilege/users/logon.do';
	}else{
		$.post("/sks/districtCommunity.do", {method:"add_attentioncommunity","buildingId":buildingId},
	    function (data){
			alert(data[0].message);
			changeCollectLabel(false);
	    }, "json");
	}
}

function del_attentioncommunity(cid) {
	var user =  '${user}';
    var a=$.cookie('individual');
	var buildingId = document.getElementById("buildingId").value;
	if ('${user}'=="nobody" || !a)
	{
		alert("请先登录！");
	    window.location.href='/sks/privilege/users/logon.do';
	}else{
		$.post("/sks/districtCommunity.do", {method:"del_attentioncommunity","buildingId":buildingId},
	    function (data){
			alert(data[0].message);
			changeCollectLabel(true);
	    }, "json");
	}
}

function changeCollectLabel(showAdd) {
	var collectDistrict = document.getElementById("collectDistrict");
	if ( collectDistrict ) {
		if (showAdd) {
			collectDistrict.innerHTML = "收藏小区";
			collectDistrict.onclick = add_attentioncommunity;
		} else {
			collectDistrict.innerHTML = "取消收藏";
			collectDistrict.onclick = del_attentioncommunity;
		}
	}
}
</script>
